// Tierless
// Copyright © 2010 Alphora
// This file is licensed under a modified BSD-license (see tierless_license.txt).

using System.Collections.Generic;
using System.ServiceModel;

using Tierless.Framework.Data;
using Tierless.Framework.Entities;
using Tierless.Framework.EntityTypes;

namespace Tierless.Framework.ServiceContracts
{
	/// <summary>
	/// Defines the service contract for managing entities.
	/// </summary>
	[ServiceContract(Namespace = "http://Tierless.Framework.ServiceContracts/2010/08", Name = "IEntityService")]
	public interface IEntityService
	{
		/// <summary>
		/// Retrieves the entities described by the given list of entity requests.
		/// </summary>
		/// <param name="lookupRequest">A list of <see cref="EntityRequest"/> instances defining the entities to be retrieved.</param>
		/// <returns>A list of <see cref="EntitySet"/> instances containing the results of the requests.</returns>
		[FaultContract(typeof (TierlessFault))]
		#if !SILVERLIGHT
		[ReferencePreservingDataContractFormat(true)]
		#endif
		[OperationContract(IsOneWay = false, AsyncPattern = false, Action = "Get")]
		List<EntitySet> Get(EntityRequests lookupRequest);

		/// <summary>
		/// Saves any outstanding changes in the given entities.
		/// </summary>
		/// <param name="entitySets">The list of entities to be saved.</param>
		/// <returns>A save result indicating whether the save was successful, and any resulting constraint violations.</returns>
		[FaultContract(typeof (TierlessFault))]
		#if !SILVERLIGHT
		[ReferencePreservingDataContractFormat(true)]
		#endif
		[OperationContract(IsOneWay = false, AsyncPattern = false, Action = "Save")]
		EntitySaveResult Save(List<EntitySet> entitySets);

		/// <summary>
		/// Describes the given entity types.
		/// </summary>
		/// <param name="entityNames">The names of the entity types to be described.</param>
		/// <returns>An array of entity type instances describing the entity types.</returns>
		[FaultContract(typeof (TierlessFault))]
		#if !SILVERLIGHT
		[ReferencePreservingDataContractFormat(true)]
		#endif
		[OperationContract(IsOneWay = false, AsyncPattern = false, Action = "Describe")]
		EntityType[] Describe(string[] entityNames);
	}
}